home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / QuickDraw3D 1.6 SDK / Mac SampleCode Previous / Viewer Samples - Mac / Tumbler and Podium / TumblerSource / Tumbler_podium.c < prev    next >
Encoding:
Text File  |  1999-05-18  |  18.9 KB  |  699 lines  |  [TEXT/MPS ]

  1. // tumbler_podium.c -- this contains the podium specific routines for the tumbler app
  2. //
  3. //
  4.  
  5.  
  6. #ifdef PODIUM_APP
  7.  
  8. #include "QD3D.h"
  9.  
  10. #include <Drag.h>
  11. #include <Events.h>
  12. #include <Controls.h>
  13. #include <ToolUtils.h>
  14. #include <Windows.h>
  15.  
  16. #include "QD3DView.h"
  17. #include "QD3DDrawContext.h"
  18. #include "QD3DDrawContext.h"
  19. #include "QD3DPick.h"
  20. #include "QD3DGroup.h"
  21. #include "QD3DTransform.h"
  22. #include "QD3DLight.h"
  23. #include "QD3DMath.h"
  24.  
  25.  
  26. #include <QuickDraw.h>
  27. #include <QDOffscreen.h>
  28.  
  29.  
  30. #include "tumbler_Document.h"
  31. #include "tumbler_Camera.h"
  32. #include "tumbler_podium.h"
  33. #include "tumbler_offscreen.h"
  34. #include "tumbler_drag.h"
  35.  
  36.  
  37. static CursHandle        objectCursor, zoomInCursor, zoomOutCursor, handCursor;
  38.  
  39.  
  40. static TQ3Object DoHitTest(DocumentPtr    theDocument);
  41. static short PointInRect(Point *point, Rect *rect);
  42.  
  43. // Used in Tumber_AEVT.c
  44. void Podium_UpdateDrawContextFromDropRect( DocumentPtr theDocument ) ;
  45.  
  46. //------------------------------------------------------------------------------------
  47. void Podium_UpdateDrawContextFromDropRect( DocumentPtr theDocument )
  48. {
  49.  
  50.     Rect                    frameRect ;
  51.     
  52.     frameRect = theDocument->dropArea ;
  53.      
  54.     // if the drop area for the doc is the same as the GWorld's rect
  55.     // then we don't need to do anything, if they have changes we need
  56.     // to update the drawcontext
  57.     
  58.     if(!EqualRect(&frameRect,&theDocument->geometriesOffscreen->portRect)) {
  59.         TQ3DrawContextObject    theDrawContext ;
  60.         OSErr                theErr ;
  61.         
  62.         if((theErr = UpdateGWorld( &theDocument->geometriesOffscreen, 32, &frameRect, nil, nil, 0L )) == noErr
  63. //            && (theErr = UpdateGWorld( &theDocument->maskOffscreen, 1, &frameRect, nil, nil, 0L )) == noErr
  64.             ) {    
  65.                         
  66.             theDrawContext = TumblerDocument_NewPixmapDrawContext( theDocument ) ;
  67.             Q3View_SetDrawContext(theDocument->theView, theDrawContext);
  68.             Q3Object_Dispose(theDrawContext);
  69.             
  70.             AdjustCamera(theDocument,
  71.                 theDocument->geometriesOffscreen->portRect.right - theDocument->geometriesOffscreen->portRect.left,
  72.                 theDocument->geometriesOffscreen->portRect.bottom - theDocument->geometriesOffscreen->portRect.top);
  73.         }
  74.     }
  75. }
  76.  
  77.         
  78.  
  79.  
  80.  
  81. static void MouseMoved(
  82.     DocumentPtr    theDocument,
  83.     long    oldX, 
  84.     long    oldY,
  85.     long    newX, 
  86.     long    newY)
  87. {
  88.     float                scaleFactor = 256.0;
  89.     unsigned long        winWidth, winHeight;
  90.     TQ3Matrix4x4        tmp;
  91.     TQ3BoundingBox         viewBBox;
  92.     TQ3Point3D            modelCenter;
  93.     
  94.     /*
  95.      *  Find the bounding box for the group.
  96.      *  We'll use the center of the box as the point about which to rotate
  97.      *  (the old method always rotated about the world-space origin).
  98.      */
  99.  
  100.     /*
  101.      *  Get the width and height of the *current* window.
  102.      *  This is done so that mouse motion in a window has an effect
  103.      *  relative to the size of the window. 
  104.      */
  105.     winWidth  = theDocument->theWindow->portRect.right - theDocument->theWindow->portRect.left;
  106.     winHeight = theDocument->theWindow->portRect.bottom - theDocument->theWindow->portRect.top;
  107.  
  108.     GetGroupBBox(theDocument->theView, theDocument->documentGroup, NULL, &viewBBox);
  109.     
  110.     /*
  111.      *  The "to" point is the center of the view bounding box
  112.      */
  113.     {
  114.         float        weights[2] = { 0.5, 0.5 };
  115.         TQ3Point3D    points[2];
  116.         
  117.         points[0] = viewBBox.min;
  118.         points[1] = viewBBox.max;
  119.         
  120.         Q3Point3D_AffineComb(points, weights, 2, &modelCenter);
  121.     }
  122.             
  123.     /*
  124.      *  Make a new rotation matrix, rotating about the center of the view
  125.      *  bbox.
  126.      */            
  127.     {
  128.         float    xRot, yRot, zRot;
  129.         
  130.         xRot = yRot = zRot = 0.0;
  131.         
  132.         xRot = Q3Math_DegreesToRadians((float)(newY - oldY) / winHeight * scaleFactor);
  133.         yRot = Q3Math_DegreesToRadians((float)(newX - oldX) / winWidth * scaleFactor);
  134.  
  135.         if ((xRot != 0.0) || (yRot != 0.0)){
  136.             Q3Matrix4x4_SetRotateAboutPoint(&tmp, &modelCenter, xRot, yRot, zRot);
  137.             Q3Matrix4x4_Multiply(&theDocument->modelRotation, &tmp, &theDocument->modelRotation);
  138.         }
  139.     }
  140.  
  141. }
  142.  
  143.  
  144. static short PointInRect(Point *point, Rect *rect)
  145. {
  146.     if( point->h > rect->left && point->h < rect->right ) {
  147.         if( point->v > rect->top && point->v < rect->bottom ) {
  148.             return(1);
  149.         } else {
  150.             return(0);
  151.         }
  152.     } else {
  153.         return(0);
  154.     }
  155. }
  156.  
  157.  
  158. static Boolean PtOnHandles(Point *newMouse, Rect *location, short *whichHandle)
  159. {
  160.     Rect    handlesRect;
  161.     
  162.     handlesRect.left = location->left - 4;
  163.     handlesRect.top = location->top - 4;
  164.     handlesRect.right = location->left;
  165.     handlesRect.bottom = location->top;
  166.     
  167.     if( PointInRect(newMouse, &handlesRect) ) {
  168.         *whichHandle = LeftTopHandle;
  169.         return(true);
  170.     }
  171.     
  172.     handlesRect.left = location->right;
  173.     handlesRect.right = location->right + 4;
  174.     
  175.     if( PointInRect(newMouse, &handlesRect) ) {
  176.         *whichHandle = RightTopHandle;
  177.         return(true);
  178.     }
  179.     
  180.     handlesRect.left = location->right;
  181.     handlesRect.right = location->right + 4;
  182.     handlesRect.top = location->bottom;
  183.     handlesRect.bottom = location->bottom + 4;
  184.     
  185.     if( PointInRect(newMouse, &handlesRect) ) {
  186.         *whichHandle = RightBottomHandle;
  187.         return(true);
  188.     }
  189.     
  190.     handlesRect.left = location->left - 4;
  191.     handlesRect.right = location->left;
  192.     
  193.     if( PointInRect(newMouse, &handlesRect) ) {
  194.         *whichHandle = LeftBottomHandle;
  195.         return(true);
  196.     }
  197.     return(false);
  198. }
  199.  
  200. static void DrawHandles(Rect *location)
  201. {
  202.     Rect    handlesRect;
  203.     
  204.     handlesRect.left = location->left - 4;
  205.     handlesRect.top = location->top - 4;
  206.     handlesRect.right = location->left;
  207.     handlesRect.bottom = location->top;
  208.     
  209.     PaintRect(&handlesRect);
  210.     
  211.     handlesRect.left = location->right;
  212.     handlesRect.right = location->right + 4;
  213.     
  214.     PaintRect(&handlesRect);
  215.     
  216.     handlesRect.left = location->right;
  217.     handlesRect.right = location->right + 4;
  218.     handlesRect.top = location->bottom;
  219.     handlesRect.bottom = location->bottom + 4;
  220.     
  221.     PaintRect(&handlesRect);
  222.     
  223.     handlesRect.left = location->left - 4;
  224.     handlesRect.right = location->left;
  225.     
  226.     PaintRect(&handlesRect);
  227.     
  228.     PenSize(2,2);
  229.     MoveTo(location->left - 2, location->top - 2);
  230.     LineTo(location->right, location->top - 2);
  231.     LineTo(location->right, location->bottom);
  232.     LineTo(location->left - 2, location->bottom);
  233.     LineTo(location->left - 2, location->top - 2);
  234.     //FrameRect(location);
  235. }
  236.  
  237. /*
  238.  *    hit test a click in the document.
  239.  */
  240.  
  241. static TQ3Object DoHitTest(DocumentPtr    theDocument)
  242. {
  243.     TQ3WindowPointPickData    withData;
  244.     unsigned long        numPicked;
  245.     TQ3PickObject        pickObject;
  246.  
  247.     withData.data.sort             =    kQ3PickSortNone;
  248.     withData.data.numHitsToReturn=    1;
  249.     withData.data.mask             =    kQ3PickDetailMaskObject;
  250.                                   
  251.     withData.point.x = theDocument->mouseLocation.h - theDocument->dropArea.left;
  252.     withData.point.y = theDocument->mouseLocation.v - theDocument->dropArea.top;
  253.  
  254.     withData.vertexTolerance = withData.edgeTolerance = 3;
  255.  
  256.     pickObject = Q3WindowPointPick_New(&withData);
  257.     if (pickObject == NULL) {
  258.         return NULL;
  259.     }
  260.  
  261.     Q3View_StartPicking(theDocument->theView, pickObject );
  262.     do {
  263.         Q3DisplayGroup_Submit(theDocument->documentGroup, theDocument->theView);
  264.     } while (Q3View_EndPicking(theDocument->theView) == kQ3ViewStatusRetraverse);
  265.     
  266.     
  267.     if (Q3Pick_GetNumHits(pickObject, &numPicked) == kQ3Success && (numPicked != 0)) {
  268.         TQ3Object            object;
  269.         TQ3PickDetail        validMask;
  270.         unsigned long        hitIndex = 1;
  271.  
  272.         object = NULL;
  273. /*        TQ3HitData hitData;
  274.         
  275.         // used to be: ErPick_GetFirstHit(pickObject, &hitData);
  276.         Q3Pick_GetHitData( pickObject, 1, &hitData );
  277.         Q3Object_Dispose(pickObject);
  278.         return(hitData.object);
  279. */
  280.         if (Q3Pick_GetPickDetailValidMask(pickObject, hitIndex, &validMask) == kQ3Success) {
  281.  
  282.             /* Quick check to see if the hit contains an object and shape part */
  283.             if (validMask & kQ3PickDetailMaskObject) {
  284.  
  285.                 /* Get reference to geometry object hit */
  286.                 Q3Pick_GetPickDetailData(    pickObject,
  287.                                             hitIndex,
  288.                                             kQ3PickDetailMaskObject,
  289.                                             &object);
  290.             }
  291.         }
  292.  
  293.         Q3Object_Dispose(pickObject);
  294.         return(object);
  295.  
  296.     } else {
  297.         Q3Object_Dispose(pickObject);
  298.         return(NULL);
  299.     }
  300. }
  301.  
  302. /*
  303.  *    DoContent handles mouseDown events in the content region of a document window.
  304.  *
  305.  *    (1)    If the mouseDown is on a control, handle the click by calling TrackControl.
  306.  *
  307.  *    (2)    If the mouseDown is on a draggable object (the document's hiliteRgn) and a
  308.  *        successful drag occurs, no further processing is necessary.
  309.  *
  310.  *    (3)    If the mouseDown is on a draggable object and the mouse is released without
  311.  *        dragging, set the insertion point to the original mouseDown location by calling
  312.  *        TEClick with the mouseDown information.
  313.  *
  314.  *    (4)    If the mouseDown is not on a draggable object and within the viewRect of the
  315.  *        TextEdit field, call TEClick to handle the mouseDown.
  316.  */
  317.  
  318. void Podium_DoContent(DocumentPtr    theDocument, EventRecord *theEvent)
  319.  
  320. {
  321.     Point            thePoint;
  322.  
  323.     SetPort(theDocument->theWindow);
  324.     thePoint = theEvent->where;
  325.  
  326.     if( theDocument->documentGroup ) {
  327.         Point     newMouse, offset;
  328.         short    whichHandle;
  329.         
  330.         GetMouse(&newMouse);
  331.         theDocument->mouseLocation = newMouse;
  332.         
  333.         /* First check for resize */
  334.         if( theDocument->currentlySelectedObject && PtOnHandles(&newMouse, &theDocument->dropArea, &whichHandle) ) {
  335.                 Rect    previousRect;
  336.                 Rect    frameRect;
  337.                 Point     oldMouse;
  338.                 TQ3Boolean    needRedraw;
  339.                 
  340.                 PenMode(srcXor);
  341.                 PenSize(2,2);
  342.                 frameRect = previousRect = theDocument->dropArea;
  343.                 
  344.                 oldMouse = theDocument->mouseLocation;
  345.                 switch( whichHandle ){
  346.                     case LeftTopHandle:
  347.                         
  348.                         offset.h = newMouse.h - frameRect.left;
  349.                         offset.v = newMouse.v - frameRect.top;
  350.  
  351.                         while (WaitMouseUp()) {
  352.                             GetMouse(&newMouse);
  353.                             if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  354.                                 newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  355.                                     needRedraw = kQ3True;
  356.                                     frameRect.left = newMouse.h - offset.h;
  357.                                     frameRect.top = newMouse.v - offset.v;
  358.                                     DrawHandles(&previousRect);
  359.                                     DrawHandles(&frameRect);
  360.                                     previousRect = frameRect;
  361.                             }
  362.                         }
  363.                     break;
  364.                     case RightTopHandle:
  365.                         
  366.                         offset.h = newMouse.h - frameRect.right;
  367.                         offset.v = newMouse.v - frameRect.top;
  368.  
  369.                         while (WaitMouseUp()) {
  370.                             GetMouse(&newMouse);
  371.                             if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  372.                                 newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  373.                                     needRedraw = kQ3True;
  374.                                     frameRect.right = newMouse.h - offset.h;
  375.                                     frameRect.top = newMouse.v - offset.v;
  376.                                     DrawHandles(&previousRect);
  377.                                     DrawHandles(&frameRect);
  378.                                     previousRect = frameRect;
  379.                             }
  380.                         }
  381.                     break;
  382.                     case LeftBottomHandle:
  383.                         
  384.                         offset.h = newMouse.h - frameRect.left;
  385.                         offset.v = newMouse.v - frameRect.bottom;
  386.  
  387.                         while (WaitMouseUp()) {
  388.                             GetMouse(&newMouse);
  389.                             if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  390.                                 newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  391.                                     needRedraw = kQ3True;
  392.                                     frameRect.left = newMouse.h - offset.h;
  393.                                     frameRect.bottom = newMouse.v - offset.v;
  394.                                     DrawHandles(&previousRect);
  395.                                     DrawHandles(&frameRect);
  396.                                     previousRect = frameRect;
  397.                             }
  398.                         }
  399.                     break;
  400.                     case RightBottomHandle:
  401.                         
  402.                         offset.h = newMouse.h - frameRect.right;
  403.                         offset.v = newMouse.v - frameRect.bottom;
  404.  
  405.                         while (WaitMouseUp()) {
  406.                             GetMouse(&newMouse);
  407.                             if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  408.                                 newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  409.                                     needRedraw = kQ3True;
  410.                                     frameRect.right = newMouse.h - offset.h;
  411.                                     frameRect.bottom = newMouse.v - offset.v;
  412.                                     DrawHandles(&previousRect);
  413.                                     DrawHandles(&frameRect);
  414.                                     previousRect = frameRect;
  415.                             }
  416.                         }
  417.                     break;
  418.                 }
  419.     
  420.                 theDocument->dropArea = frameRect;
  421.                 
  422.                 if( needRedraw == kQ3True ) {
  423.                     Podium_UpdateDrawContextFromDropRect( theDocument ) ;
  424.                     DrawOffscreen(theDocument);
  425.                     DrawOnscreen(theDocument);
  426.                     
  427.                 }
  428.                         
  429.                 PenMode(srcXor);
  430.                 PenSize(2,2);
  431.                 PenPat(&qd.black);
  432.                 DrawHandles(&frameRect);
  433.         /* is it in content */
  434.         } else if( PtInRect(newMouse, &theDocument->dropArea) ) {
  435. //            TQ3Object    newPick;
  436. //        if(( newPick = DoHitTest(theDocument)) != NULL) {
  437.             if( theDocument->selected == kQ3False) {
  438.                 PenMode(srcXor);
  439.                 PenSize(2,2);
  440.                 PenPat(&qd.black);
  441.                 DrawHandles(&theDocument->dropArea);
  442.             }
  443.             
  444.             theDocument->currentlySelectedObject = theDocument->documentGroup ;
  445.             
  446.             if( theEvent->modifiers & shiftKey )
  447.                 SetCursor(*zoomInCursor);
  448.             else if( theEvent->modifiers & cmdKey )
  449.                 SetCursor(*zoomOutCursor);
  450.             else
  451.                 SetCursor(*objectCursor);
  452.         
  453.             if( theEvent->modifiers & shiftKey ) {
  454.                 TQ3Matrix4x4    tmp;
  455.                 
  456.                 Q3Matrix4x4_SetScale(&tmp, 1.2, 1.2, 1.2);
  457.                 while (WaitMouseUp()) {
  458.                     Q3Matrix4x4_Multiply(&tmp, &theDocument->modelRotation, &theDocument->modelRotation);
  459.                     DrawOffscreen( theDocument ) ;
  460.                     DrawOnscreen( theDocument ) ;
  461.                 }
  462.             } else if( theEvent->modifiers & cmdKey ) {
  463.                 TQ3Matrix4x4    tmp;
  464.                 
  465.                 Q3Matrix4x4_SetScale(&tmp, 0.83333, 0.83333, 0.83333);
  466.                 while (WaitMouseUp()) {
  467.                     Q3Matrix4x4_Multiply(&tmp, &theDocument->modelRotation, &theDocument->modelRotation);
  468.                     DrawOffscreen(theDocument);
  469.                     DrawOnscreen( theDocument ) ;
  470.                 }
  471.             } else if( theEvent->modifiers & controlKey ) {
  472.             
  473.                 Point     newMouse;
  474.                 long     mouseChanged = 0;
  475.                 long    dx, dy, oldX, oldY;
  476.                 float    width, height;
  477.                 float    xRot, yRot;
  478.                         
  479.                 SetCursor(*handCursor);
  480.                 GetMouse(&newMouse);        // get the mouse in local co-ordinates, 
  481.                                                 // local to the  current GrafPort
  482.         
  483.                 oldX = newMouse.h;
  484.                 oldY = newMouse.v;
  485.                 
  486.                 width = theDocument->geometriesOffscreen->portRect.right - theDocument->geometriesOffscreen->portRect.left;
  487.                 height =  theDocument->geometriesOffscreen->portRect.bottom - theDocument->geometriesOffscreen->portRect.top;
  488.     
  489.                 while (WaitMouseUp()) {
  490.                 
  491.                     GetMouse(&newMouse);        // get the mouse in local co-ordinates, 
  492.                                                 // local to the  current GrafPort
  493.     
  494.                     dx = newMouse.v - oldY;
  495.                     dy = newMouse.h - oldX;
  496.                     
  497.                     if ((dx != 0) || (dy != 0)) {
  498.                         TQ3Matrix4x4        tempMatrix;
  499.                         
  500.                         xRot = ((float) dx * kQ3Pi) / width;
  501.                         yRot = ((float) dy * kQ3Pi) / height;
  502.             
  503.                         if ((xRot != 0.0) || (yRot != 0.0)) {
  504.                             Q3Matrix4x4_SetRotate_XYZ(&tempMatrix, xRot, yRot, 0.0);
  505.                             Q3Matrix4x4_Multiply(&theDocument->modelRotation, &tempMatrix, &theDocument->modelRotation);
  506.     
  507.                             mouseChanged = 1;
  508.                             DrawOffscreen(theDocument);
  509.                             DrawOnscreen( theDocument ) ;
  510.                         }
  511.                     }
  512.                     oldX = newMouse.h; oldY = newMouse.v;
  513.                 }
  514.                 
  515.                 if( mouseChanged ) {
  516.                     theDocument->rotationDir.x = xRot;
  517.                     theDocument->rotationDir.y = yRot;
  518.                 }
  519.             } else {
  520.                 Rect    previousRect;
  521.                 Rect    frameRect;
  522.                 Point     oldMouse;
  523.                 TQ3Boolean    needRedraw;
  524.                 long    height, width;
  525.                 
  526.                 PenMode(srcXor);
  527.                 PenSize(2,2);
  528.                 frameRect = previousRect = theDocument->dropArea;
  529.                 height = frameRect.bottom - frameRect.top;
  530.                 width = frameRect.right - frameRect.left;
  531.                 
  532.                 offset.h = newMouse.h - frameRect.left;
  533.                 offset.v = newMouse.v - frameRect.top;
  534.                 
  535.                 oldMouse = theDocument->mouseLocation;
  536.                 while (WaitMouseUp()) {
  537.                     GetMouse(&newMouse);
  538.                     if (newMouse.h >= oldMouse.h +  2 || newMouse.h <= oldMouse.h - 2 ||
  539.                         newMouse.v >= oldMouse.v +  2 || newMouse.v <= oldMouse.v - 2) {
  540.                             needRedraw = kQ3True;
  541.                             frameRect.left = newMouse.h - offset.h;
  542.                             frameRect.top = newMouse.v - offset.v;
  543.                             frameRect.right = frameRect.left + width;
  544.                             frameRect.bottom = frameRect.top + height;
  545.                             DrawHandles(&previousRect);
  546.                             DrawHandles(&frameRect);
  547.                             previousRect = frameRect;
  548.                     }
  549.                 }
  550.     
  551.                 theDocument->dropArea = frameRect;
  552.                 
  553.                 if( needRedraw == kQ3True ) {
  554.                     Podium_UpdateDrawContextFromDropRect( theDocument ) ;
  555.                     DrawOffscreen(theDocument);
  556.                     DrawOnscreen(theDocument);
  557.                         
  558.                 }
  559.                 PenMode(srcXor);
  560.                 PenSize(2,2);
  561.                 PenPat(&qd.black);
  562.                 DrawHandles(&frameRect);
  563.             }
  564.         } else {
  565.             if( theDocument->selected == kQ3True) {
  566.                 theDocument->currentlySelectedObject = NULL;
  567.                 theDocument->selected = kQ3False;
  568.                 PenMode(srcXor);
  569.                 PenSize(2,2);
  570.                 PenPat(&qd.black);
  571.                 DrawHandles(&theDocument->dropArea);
  572.             }
  573.             SetCursor(&qd.arrow);
  574.         }
  575.     } 
  576.     else  {
  577.     
  578.         if( theDocument->currentlySelectedObject ) {
  579.             theDocument->currentlySelectedObject = NULL;
  580.             PenMode(srcXor);
  581.             PenSize(2,2);
  582.             DrawHandles(&theDocument->dropArea);
  583.             SetCursor(&qd.arrow);
  584.         }
  585.     }
  586. }
  587.  
  588.  
  589. /*
  590.  *    DoBackgroundContent handles mouseDown events in the content region of a document window
  591.  *    when the window is not frontmost. The following bullet items describe how this background
  592.  *    mouseDown event is handled:
  593.  *
  594.  *    (1)    If the mouseDown is not in a draggable object (not in the document's hiliteRgn) call
  595.  *        SelectWindow to bring the window to the front as usual.
  596.  *
  597.  *    (2)    If the mouseDown is in a draggable object and the mouse is released without
  598.  *        dragging, call SelectWindow when the mouse is released.
  599.  *
  600.  *    (3)    If the mouseDown is in a draggable object and a successful drag occurs, SelectWindow
  601.  *        should only be called if the drop occurred in the same window (the DragText function
  602.  *        calls SelectWindow in this case).
  603.  */
  604.  void Podium_DoBackgroundContent(DocumentPtr    theDocument, EventRecord *theEvent)
  605.  
  606. {
  607.     Point            thePoint;
  608.     RgnHandle        tempRgn = NewRgn();  // Nick this needs to be the BBox of the group
  609.  
  610.     SetPort(theDocument->theWindow);
  611.     thePoint = theEvent->where;
  612.     GlobalToLocal(&thePoint);
  613.  
  614.     RectRgn(tempRgn, &theDocument->geometriesOffscreen->portRect);
  615.  
  616.     if (PtInRgn(thePoint,tempRgn)) {
  617.         if (! DoDragObjects(theDocument, theEvent, tempRgn)) {
  618.             SelectWindow(theDocument->theWindow);
  619.         }
  620.     } 
  621.     else {
  622.         SelectWindow(theDocument->theWindow);
  623.     }
  624.     
  625.     DisposeRgn(tempRgn);
  626. }
  627.  
  628.  
  629.  
  630.  
  631. /*
  632.  *    DoIdle get called repetitively while the application is not doing
  633.  *    anything.
  634.  */
  635.  
  636. void Podium_DoIdle(EventRecord *theEvent)
  637. {
  638.     WindowPtr        theWindow;
  639.     DocumentPtr    theDocument;
  640.  
  641.     if ((theWindow = FrontWindow()) != nil) {
  642.         if ((theDocument = GetDocumentFromWindow(theWindow)) != nil) {
  643.             SetPort(theDocument->theWindow);
  644.  
  645.             if( theDocument->documentGroup ) {
  646.                 Point     mouseLocation;
  647.                 
  648.                 GetMouse(&mouseLocation);
  649.  
  650.                  theDocument->mouseLocation = mouseLocation;
  651.                  
  652.                  if( PointInRect(&theDocument->mouseLocation, &theDocument->dropArea) ) {
  653.                     if(/*DoHitTest(theDocument)*/1) {
  654.                         if( theEvent->modifiers & shiftKey) {
  655.                             SetCursor(*zoomInCursor);
  656.                         } else if( theEvent->modifiers & cmdKey) {
  657.                             SetCursor(*zoomOutCursor);
  658.                         } else if( theEvent->modifiers & controlKey) {
  659.                             SetCursor(*handCursor);
  660.                         } else {
  661.                             SetCursor(*objectCursor);
  662.                         }
  663.                     } else {
  664.                         SetCursor(&qd.arrow);
  665.                     }
  666.                 } else {
  667.                     SetCursor(&qd.arrow);
  668.                 }
  669.                 
  670.                 if( theDocument->animateModel == kQ3True) {
  671.                     TQ3Matrix4x4    tmp;
  672.                     
  673.                     if( theDocument->rotationDir.x == 0.0 && theDocument->rotationDir.y == 0.0 ) {
  674.                         Q3Matrix4x4_SetRotate_XYZ(&tmp, 0.03, 0.08, 0.0);
  675.                         Q3Matrix4x4_Multiply(&theDocument->modelRotation, &tmp, &theDocument->modelRotation);
  676.                     } else {
  677.                         Q3Matrix4x4_SetRotate_XYZ(&tmp, theDocument->rotationDir.x, theDocument->rotationDir.y, 0.0);
  678.                         Q3Matrix4x4_Multiply(&theDocument->modelRotation, &tmp, &theDocument->modelRotation);
  679.                     }
  680.                     DrawOffscreen(theDocument);
  681.                     DrawOnscreen(theDocument);
  682.                 }
  683.             }
  684.         }
  685.     }
  686. }
  687.  
  688. void Podium_Init(void)
  689. {
  690.     objectCursor = GetCursor(132);
  691.     zoomInCursor = GetCursor(133);
  692.     zoomOutCursor = GetCursor(134);
  693.     handCursor = GetCursor(130);
  694. }
  695.  
  696.  
  697.  
  698. #endif /* PODIUM_APP */
  699.